<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.css
    ">
</head>

<body>
    <div class="father">
        <i class="fa fa-cog" aria-hidden="true"></i>
    </div>
</body>
<style>
    .father {
        background-color: #49B1F5;
        width: 30px;
        height: 30px;
        display: flex;
        justify-content: center;
        align-items: center;
        transition: transform 1s ease;
    }

    .father:hover {
        background-color: #FF7242
    }

    i {
        animation: a 7s infinite linear;
        color: #fff;
    }

    @keyframes a {
        from {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(360deg);
        }
    }

    .goaway {
        transform: translateX(-200%);
    }
</style>
<script>
    const boxes = document.querySelectorAll('.father')[0]
    boxes.onclick= () => {
        boxes.classList.add('goaway')
        setTimeout(() => {
            boxes.classList.remove('goaway')
        }, 500);
    }
</script>

</html>